package com.cwj;

import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author: Chenwujie
 * @date: 2021-06-22 17:08
 */
public class StreamTest {
    public static void main(String[] args) {
        Map<String, String> map = getMap();
        List<String> list = new ArrayList<>();
        map.forEach((k, v) ->{
            list.add(k);
        });
        System.out.println(list.size());
    }
    public static Map getMap(){
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 100000; i++) {
            list.add(i);
        }
        Map<String, String> map = new HashMap<>();
        AtomicInteger i = new AtomicInteger();
        list.parallelStream().forEach(e -> {
            map.put(e.toString(), "1");
            i.incrementAndGet();
        });
        System.out.println("map size: " + map.size());
        System.out.println("foreach num: " + i.get());
        return map;
    }
}
